﻿using Core.Domain.Entities;
using Core.Migrations.Extensions;
using FluentMigrator;

namespace Infrastructure.Persistence.Migrations.Tenants;

[Migration(202511042231)]
public class CreateTableForTenantPermissionHistory : ForwardOnlyMigration
{
    public override void Up()
    {
        MigrationExpressions.CreateTableAuditableEntityFor<TenantPermissionHistory>(Create, SchemaNames.Identity);

        Alter.Table(typeof(TenantPermissionHistory).GetTableName())
         .InSchema(SchemaNames.Identity).AddColumn("TenantId").AsString(100).Nullable().WithColumnDescription("租户标识")
         .AddColumn(MigrationExpressions.ColumnNameFor<TenantPermissionHistory>(nameof(TenantPermissionHistory.BoilerplateTenantInfoId))).AsString(100).Nullable().WithColumnDescription("关联的租户ID")
         .AddColumn(MigrationExpressions.ColumnNameFor<TenantPermissionHistory>(nameof(TenantPermissionHistory.PermissionId))).AsGuid().Nullable().WithColumnDescription("权限ID")
         .AddColumn(MigrationExpressions.ColumnNameFor<TenantPermissionHistory>(nameof(TenantPermissionHistory.AssignmentBatchId))).AsGuid().Nullable().WithColumnDescription("分配批次号"); 
    }
}
